$(function() {
	 var calendarElement = document.createElement("div");
	 calendarElement.id = "calendarDiv";
	 calendarElement.style.display = "none"; 
	 calendarElement.style.width = "252px"; 
	 calendarElement.style.position = "absolute"; 
	 calendarElement.style.zIndex = "999999"; 
	 calendarElement.style.borderTopWidth = "1px"; 
	 calendarElement.style.borderRightWidth = "1px"; 
	 calendarElement.style.borderBottomWidth = "1px"; 
	 calendarElement.style.borderLeftWidth = "1px"; 
	 calendarElement.style.borderTopStyle = "groove"; 
	 calendarElement.style.borderRightStyle = "groove"; 
	 calendarElement.style.borderBottomStyle = "groove"; 
	 calendarElement.style.borderLeftStyle = "groove"; 
	 calendarElement.style.borderTopColor = "rgb(102, 153, 204)"; 
	 calendarElement.style. borderRightColor = "rgb(102, 153, 204)"; 
	 calendarElement.style.borderBottomColor = "rgb(102, 153, 204)"; 
	 calendarElement.style.borderLeftColor = "rgb(102, 153, 204)"; 
	 calendarElement.style.borderImage = "initial"; 
	 calendarElement.style.paddingTop = "2px"; 
	 calendarElement.style.paddingRight = "2px"; 
	 calendarElement.style.paddingBottom = "2px"; 
	 calendarElement.style.paddingLeft = "2px"; 
	 calendarElement.style.backgroundColor = "rgb(255, 220, 253)";
	 document.body.appendChild(calendarElement);

	 var calendarInnerHTML = "";
	 calendarInnerHTML += "<center>";
	 calendarInnerHTML += "	<table width=\"250px\" border=\"0\" class=\"cal\">";
	 calendarInnerHTML += "		<tr>";
//	 calendarInnerHTML += "			<td align=\"center\">";
//	 calendarInnerHTML += "				";
//	 calendarInnerHTML += "			</td>";
//	 calendarInnerHTML += "			<td align=\"right\" width=\"20px\">";
	 calendarInnerHTML += "			<td align=\"right\" colspan=\"2\">";
	 calendarInnerHTML += "				<label id=\"calendarClose\"></label>";
	 calendarInnerHTML += "			</td>";
	 calendarInnerHTML += "		</tr>";
	 calendarInnerHTML += "		<tr>";
	 calendarInnerHTML += "			<td colspan=\"2\">";
	 calendarInnerHTML += "				<div>";
	 calendarInnerHTML += "					<table width=\"100%\" height=\"20px\" border=\"0\" class=\"cal\">";
	 calendarInnerHTML += "						<tr>";
	 calendarInnerHTML += "							<td align=\"center\" width=\"32px\" height=\"20px\"><label id=\"calendarPreYear\"></label></td>";
	 calendarInnerHTML += "							<td align=\"center\" width=\"20px\" height=\"20px\"><label id=\"calendarPreMonth\"></label></td>";
	 calendarInnerHTML += "							<td align=\"center\"><label id=\"calendarYear\"></label>&nbsp;年&nbsp;<label id=\"calendarMonth\"></label>&nbsp;日</td>";
	 calendarInnerHTML += "							<td align=\"center\" width=\"20px\" height=\"20px\"><label id=\"calendarNextMonth\"></label></td>";
	 calendarInnerHTML += "							<td align=\"center\" width=\"32px\" height=\"20px\"><label id=\"calendarNextYear\"></label></td>";
	 calendarInnerHTML += "						</tr>";
	 calendarInnerHTML += "					</table>";
	 calendarInnerHTML += "				</div>";
	 calendarInnerHTML += "			</td>";
	 calendarInnerHTML += "		</tr>";
	 calendarInnerHTML += "		<tr>";
	 calendarInnerHTML += "			<td colspan=\"2\">";
	 calendarInnerHTML += "				<div id=\"calendarContextDiv\"></div>";
	 calendarInnerHTML += "			</td>";
	 calendarInnerHTML += "		</tr>";
	 calendarInnerHTML += "	</table> ";
	 calendarInnerHTML += "</center>";
	 calendarInnerHTML += "<IFRAME style=\"DISPLAY: block; Z-INDEX: -1; FILTER: Alpha(Opacity='0'); LEFT: -1px; ; LEFT: expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+'px'); WIDTH: 102px; ; WIDTH: expression(this.parentNode.offsetWidth+'px'); POSITION: absolute; TOP: -1px; ; TOP: expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+'px'); HEIGHT: 80px; ; HEIGHT: expression(this.parentNode.offsetHeight+'px')\"  tabIndex=-1 src=\"javascript:false;\" frameBorder=0></IFRAME>";
	 document.getElementById("calendarDiv").innerHTML = calendarInnerHTML;
});


var nowCalendarPath="";
function initCalendar(path){
	nowCalendarPath=path;
	document.getElementById('calendarClose').innerHTML="<a href=\"javascript:\" onclick=\"closeCalendar();\" onkeypress=\"closeCalendar();\" title=\"關閉\" ><img src=\""+nowCalendarPath+"/base/image/calendar/calendarClose.gif\" border=\"0\" style=\"vertical-align:top;\" ></a>";
	document.getElementById("calendarPreYear").innerHTML="<a id=\"calendarPreYearLink\" href=\"javascript:\" title=\"上一年\" ><img src=\""+nowCalendarPath+"/base/image/calendar/calendarPre02.gif\" border=\"0\" style=\"vertical-align:top;\" /></a>";
	document.getElementById("calendarPreMonth").innerHTML="<a id=\"calendarPreMonthLink\" href=\"javascript:\" title=\"上一月\"><img src=\""+nowCalendarPath+"/base/image/calendar/calendarPre01.gif\" border=\"0\" style=\"vertical-align:top;\" /></a>";
	document.getElementById("calendarNextMonth").innerHTML="<a id=\"calendarNextMonthLink\" href=\"javascript:\" title=\"下一月\" ><img src=\""+nowCalendarPath+"/base/image/calendar/calendarNext01.gif\" border=\"0\" style=\"vertical-align:top;\" /></a>";
	document.getElementById("calendarNextYear").innerHTML="<a id=\"calendarNextYearLink\" href=\"javascript:\" title=\"下一年\" ><img src=\""+nowCalendarPath+"/base/image/calendar/calendarNext02.gif\" border=\"0\" style=\"vertical-align:top;\" /></a>";

}

//取得位置所需使用的function
Number.prototype.calendarNaN0=function(){return isNaN(this)?0:this;}

//取得日曆按鈕的位置
function getCalendarPosition(e){
	var left=0;
	var top=0;
	while(e.offsetParent){
		left+=e.offsetLeft+(e.currentStyle?(parseInt(e.currentStyle.borderLeftWidth)).calendarNaN0():0);
		top+=e.offsetTop+(e.currentStyle?(parseInt(e.currentStyle.borderTopWidth)).calendarNaN0():0);
		e=e.offsetParent;
	}
	left+=e.offsetLeft+(e.currentStyle?(parseInt(e.currentStyle.borderLeftWidth)).calendarNaN0():0);
	top+=e.offsetTop+(e.currentStyle?(parseInt(e.currentStyle.borderTopWidth)).calendarNaN0():0);
	return {x:left, y:top};
}

//開啟日曆小視窗
function openCalendar(e, dateType, calendarId){
	var calendarButtton="calendarImg_"+calendarId;
	var year;
	var month;
	if(document.getElementById(calendarId).value!=""){
		var dateValue=document.getElementById(calendarId).value.split("/");
		if(dateType=="AD"){
			year=dateValue[0];
		}else if(dateType=="ROC"){
			year=String(Number(dateValue[0])+1911);
		}
		month=String(Number(dateValue[1])-1);
		day=dateValue[2];
	}else{
		var today = new Date();
		year=today.getFullYear();
		month=today.getMonth();
		day=today.getDate();
	}

	//取得日曆小視窗開啟的位置
	var calendarPosition = getCalendarPosition(document.getElementById(calendarButtton));
	var left=(calendarPosition.x-1);
	var top;
	if(document.documentElement.clientWidth<(e.clientX+200)){
		left=(calendarPosition.x-190);
	}else{
		left=(calendarPosition.x-1);
	}
	if(document.documentElement.clientHeight<(e.clientY+200)){
		top=(calendarPosition.y-196);
	}else{
		top=(calendarPosition.y+16);
	}
	document.getElementById('calendarDiv').style.left=left+"px";
	document.getElementById('calendarDiv').style.top=top+"px";
	calendarInit(dateType, year, month, day, calendarId);

}

//建立日曆小視窗的初始值
function calendarInit(dateType, year, month, day, calendarId){
	var showYear=year;
	var showMonth=month;
	if(dateType=="AD"){
	}else if(dateType=="ROC"){
		showYear=String(Number(showYear)-1911);
		if(showYear.length==2){
			showYear="0"+showYear;
		}
	}
	showMonth=String(Number(showMonth)+1);
	if(showMonth.length<2){
		showMonth="0"+showMonth;
	}
	document.getElementById("calendarYear").innerHTML=showYear;
	document.getElementById("calendarMonth").innerHTML=showMonth;
	createCalendarContext(dateType, year, month, day, calendarId);
//	document.getElementById("calendarPreYear").innerHTML="<a href=\"javascript:\" onclick=\"changeDate('"+dateType+"', -1, 0, '"+calendarId+"')\" onkeypress=\"changeDate('"+dateType+"', -1, 0, '"+calendarId+"')\" title=\"上一年\" ><img src=\""+nowCalendarPath+"/base/image/calendar/calendarPre02.gif\" border=\"0\" style=\"vertical-align:top;\" /></a>";
//	document.getElementById("calendarPreMonth").innerHTML="<a href=\"javascript:\" onclick=\"changeDate('"+dateType+"', 0, -1, '"+calendarId+"')\" onkeypress=\"changeDate('"+dateType+"', 0, -1, '"+calendarId+"')\" title=\"上一月\"><img src=\""+nowCalendarPath+"/base/image/calendar/calendarPre01.gif\" border=\"0\" style=\"vertical-align:top;\" /></a>";
//	document.getElementById("calendarNextMonth").innerHTML="<a href=\"javascript:\" onclick=\"changeDate('"+dateType+"', 0, 1, '"+calendarId+"')\" onkeypress=\"changeDate('"+dateType+"', 0, 1, '"+calendarId+"')\" title=\"下一月\" ><img src=\""+nowCalendarPath+"/base/image/calendar/calendarNext01.gif\" border=\"0\" style=\"vertical-align:top;\" /></a>";
//	document.getElementById("calendarNextYear").innerHTML="<a href=\"javascript:\" onclick=\"changeDate('"+dateType+"', 1, 0, '"+calendarId+"')\" onkeypress=\"changeDate('"+dateType+"', 1, 0, '"+calendarId+"')\" title=\"下一年\" ><img src=\""+nowCalendarPath+"/base/image/calendar/calendarNext02.gif\" border=\"0\" style=\"vertical-align:top;\" /></a>";
	document.getElementById("calendarPreYearLink").onclick = new Function("changeDate('"+dateType+"', -1, 0, '"+calendarId+"')");
	document.getElementById("calendarPreMonthLink").onclick = new Function("changeDate('"+dateType+"', 0, -1, '"+calendarId+"')");
	document.getElementById("calendarNextMonthLink").onclick = new Function("changeDate('"+dateType+"', 0, 1, '"+calendarId+"')");
	document.getElementById("calendarNextYearLink").onclick = new Function("changeDate('"+dateType+"', 1, 0, '"+calendarId+"')");
	document.getElementById("calendarDiv").style.display="block";
}

//定義月份天數
function arrMonth(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11){
	this[0] = m0;
	this[1] = m1;
	this[2] = m2;
	this[3] = m3;
	this[4] = m4;
	this[5] = m5;
	this[6] = m6;
	this[7] = m7;
	this[8] = m8;
	this[9] = m9;
	this[10] = m10;
	this[11] = m11;
}

//根據日曆小視窗的初始值建立日曆內容
function createCalendarContext(dateType, year, month, day, calendarId){
	var newDate = new Date(year, month);
	var today = new Date();
	var thisDay;
	var monthDays = new arrMonth(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	var calendarTextYear;
	var calendarTextMonth;
	var calendarTextDay;
	if(document.getElementById(calendarId).value!=""){		
		var calendarTextDate=document.getElementById(calendarId).value.split("/");
		if(dateType=="AD"){
			calendarTextYear=calendarTextDate[0];
		}else if(dateType=="ROC"){
			calendarTextYear=String(Number(calendarTextDate[0])+1911);
		}
		calendarTextMonth=String(Number(calendarTextDate[1])-1);
		calendarTextDay=calendarTextDate[2];
		
		if(newDate.getFullYear()==calendarTextYear&&newDate.getMonth()==calendarTextMonth){
			thisDay=calendarTextDay;
		}
	}else{
		if(today.getFullYear()==year&&today.getMonth()==month){
			thisDay = today.getDate();
		} 
	}

	if (((newDate.getFullYear()%4==0)&&(newDate.getFullYear()%100!=0))||(newDate.getFullYear()%400==0)){ 
		monthDays[1] = 29;
	}

	var nDays = monthDays[newDate.getMonth()];

	var firstDay = newDate;
	firstDay.setDate(1); // works fine for most systems
	testMe = firstDay.getDate();
	if (testMe==2){
		firstDay.setDate(0);
	}
	var startDay = firstDay.getDay();

	var str="<table border=\"0\" width=\"100%\" class=\"cal\">";
	str=str+"	<tr>";
	str=str+"		<th align=\"center\" width=\"20px\">日</th>";
	str=str+"		<th align=\"center\" width=\"20px\">一</th>";
	str=str+"		<th align=\"center\" width=\"20px\">二</th>";
	str=str+"		<th align=\"center\" width=\"20px\">三</th>";
	str=str+"		<th align=\"center\" width=\"20px\">四</th>";
	str=str+"		<th align=\"center\" width=\"20px\">五</th>";
	str=str+"		<th align=\"center\" width=\"20px\">六</th>";
	str=str+"	</tr>";
	str=str+"	<tr>";
	var column=0;
	var row=0;
	var	preDays;
	if(newDate.getMonth()==0){
		preDays=monthDays[11]
	}else{
		preDays=monthDays[newDate.getMonth()-1];
	}

	for(var i=1;i<=startDay;i++){
		str=str+"<td align=\"center\" height=\"20px\">"+(preDays-startDay+i)+"</td>";
		column++;
	}

	for(var i=1;i<=nDays;i++){
		if(i==thisDay){
			str=str+"</td><td align=\"center\" style=\"background:#ffcccc\" height=\"20px\">";
		}else{
			str=str+"</td><td align=\"center\" height=\"20px\">";
		}
		str=str+"<a href=\"javascript:\" onclick=\"copyDate('"+dateType+"', '"+newDate.getFullYear()+"', '"+Number(newDate.getMonth()+1)+"', '"+i+"', '"+calendarId+"')\">"+i+"</a>";
		str=str+"</td>";
		column++;
		if (column==7){
			row++;
			str=str+"</tr>";
			column=0;
		}
	}

	var	newDay=1;
	if(column!=7){
		var columnNum=column;
		for(var i=newDay;i<=7-columnNum; i++){
			str=str+"<td align=\"center\" height=\"20px\">"+(newDay++)+"</td>";
			column++;
		}
		if(column==7){
			row++;
			str=str+"</tr>";
			column=0;
		}
	}

	if(row!=6){
		str=str+"<tr>";
		for(var i=newDay;i<newDay+7; i++){
			str=str+"<td align=\"center\" height=\"20px\">"+i+"</td>";
			column++;	
		}
		row++;
		str=str+"</tr>";
		column=0;		
	}
	str=str+"</table>";
	document.getElementById('calendarContextDiv').innerHTML=str;
}

//改變日曆小視窗的年,月
function changeDate(dateType, addYearNum, addMonthNum, calendarId){
	var year=document.getElementById('calendarYear').innerHTML;
	var month=document.getElementById('calendarMonth').innerHTML;
	year=Number(year)+addYearNum;
	month=Number(month)+addMonthNum;
	if(month==0){
		year=Number(year)-1;
		month=12;
	}else if(month==13){
		year=Number(year)+1;
		month=1;
	}
	
	var showYear=String(year);
	if(dateType=="AD"){

	}else if(dateType=="ROC"){
		year=year+1911;
		if(showYear.length<3){
			showYear="0"+showYear;
		}
	}
	var showMonth=String(month);
	if(showMonth.length<2){
		showMonth="0"+showMonth;
	}
	document.getElementById('calendarYear').innerHTML=showYear;
	document.getElementById('calendarMonth').innerHTML=showMonth;
	createCalendarContext(dateType, year, month-1, 0, calendarId);
}

//複製日期到text
function copyDate(dateType, year, month, day, calendarId){
	if(dateType=="AD"){

	}else if(dateType=="ROC"){
		year=Number(year)-1911;
		if(String(year).length<3){
			year="0"+year;
		}
	}
	
	if(String(month).length<2){
		month="0"+month;
	}
	if(String(day).length<2){
		day="0"+day;
	}
	document.getElementById(calendarId).value=year+"/"+month+"/"+day;
	document.getElementById(calendarId).focus();
	closeCalendar();
}

//關閉日曆小視窗
function closeCalendar(){
	document.getElementById('calendarDiv').style.display="none";
}

/*
 * 日期輸入格式檢查[function setDateConstraint(事件, 檢查物件, 日期型態)]
 * Return：字元
 */
function setDateConstraint(e, obj, dateType){
	var iKeyCode = window.event?e.keyCode:e.which;
	var isIE = false;
	var isFF = false;
	
	/*
	 * ie9: parseInt(navigator.appVersion)=5
	 * ie6: parseInt(navigator.appVersion)=4
	 * ie9的event跟firefox的物件為同一物件型態，故parseInt(navigator.appVersion)限定ie8以下
	 */
//	if ((navigator.userAgent.indexOf("MSIE")>0) && (parseInt(navigator.appVersion) >= 4)){
	if ((navigator.userAgent.indexOf("MSIE")>0) && (parseInt(navigator.appVersion) == 4)){
		isIE = true;
	}
	
	if (navigator.userAgent.indexOf("Firefox")>0){
		isFF = true;
	}

	//if(!(((iKeyCode >= 48) && (iKeyCode <= 57)) || (iKeyCode == 13) || (iKeyCode == 46) || (iKeyCode == 45) || (iKeyCode == 37) || (iKeyCode == 39) || (iKeyCode == 8) || (iKeyCode == 47))){
	if(!(((iKeyCode >= 48) && (iKeyCode <= 57)) || (iKeyCode == 47))){
		if (isIE){
			e.returnValue = false;
		}else{
			e.preventDefault();   //重要 firefox是用prevenDefault()来取消事件的
		}
	}else{
		if(dateType == "AD"){
			if( (iKeyCode != 47) && (obj.value.length == 4 || obj.value.length == 7) ) {
				obj.value = obj.value+"/";
			}
		}else{
			if((obj.value.length == 1)&&(obj.value != "1")&&(obj.value != "0")){
				obj.value = "0" + obj.value;
			}
			
			if( (iKeyCode != 47) && (obj.value.length == 3 || obj.value.length == 6) ) {
				obj.value = obj.value+"/";
			}
		}
	}
	
	/*
	var keyCode = whichKeyPress(event);
	if(!((keyCode == 37) || (keyCode == 39) || (keyCode == 8))){
		obj.value = obj.value.replace(/[^0-9\/]/g,'');
		var value = obj.value;
		var temp1 = "";
		var temp2 = "";
		var temp3 = "";
		var temp4 = "";
		var temp5 = "";		

		if(dateType == "AD"){
			if(value.length < 4){
				obj.value = value.replace(/[^0-9]/g,'');
				return;
			}else{
				obj.value = value.replace(/[^0-9\/]/g,'');
			}

			if(value.length < 4){
				value = value.replace(/[^0-9]/g,'');
				temp1 = obj.value;
			}else{
				temp1 = value.substring(0, 4);
				temp1 = temp1.replace(/[^0-9]/g,'');
				if(value.length >= 5){
					temp2 = value.substring(4, 5);
					temp2 = temp2.replace(/[^\/]/g,'');
				}
				if(value.length >= 6 ){
					if(value.length ==6 ){
						temp3 = value.substring(5, 6);
					}else{
						temp3 = value.substring(5, 7);
					}
					temp3 = temp3.replace(/[^0-9]/g,'');
				}
				if(value.length >=8 ){
					temp4 = value.substring(7, 8);
					temp4 = temp4.replace(/[^\/]/g,'');
				}
				if(value.length > 8 ){
					temp5 = value.substring(8);
					temp5 = temp5.replace(/[^0-9]/g,'');
				}
			}
			value = temp1 + temp2 + temp3 + temp4 + temp5 ;
			obj.value = value;
			if(value.length >= 4){
				if(value.length == 4){
					obj.value = value + "/";
				}
				if(value.length == 7){
					obj.value = value + "/";
				}
			}
		}else if(dateType=="ROC"){
			if(value.length < 3){
				obj.value = value.replace(/[^0-9]/g,'');
				return;
			}else{
				obj.value = value.replace(/[^0-9\/]/g,'');
			}

			if((value.length == 1)&&(value != "1")&&(value != "0")){
				obj.value = "0" + value;
				return;
			}

			if((value.length == 3)&&(keyCode == 111)){
				obj.value = "0" + value;
				return;
			}

			if(value.length < 3){
				value = value.replace(/[^0-9]/g,'');
				temp1 = obj.value;
			}else{
				temp1 = value.substring(0, 3);
				temp1 = temp1.replace(/[^0-9]/g,'');
				if(value.length >= 4){
					temp2 = value.substring(3, 4);
					temp2 = temp2.replace(/[^\/]/g,'');
				}
				if(value.length >= 5 ){
					if(value.length ==5 ){
						temp3 = value.substring(4, 5);
					}else{
						temp3 = value.substring(4, 6);
					}
					temp3 = temp3.replace(/[^0-9]/g,'');
				}
				if(value.length >=7 ){
					temp4 = value.substring(5, 7);
					temp4 = temp4.replace(/[^\/]/g,'');
				}
				if(value.length > 7 ){
					temp5 = value.substring(7);
					temp5 = temp5.replace(/[^0-9]/g,'');
				}
			}
			value = temp1 + temp2 + temp3 + temp4 + temp5 ;
			obj.value = value;

			if(value.length >= 3){
				if(value.length == 3){
					obj.value = value + "/";
					return;
				}
				if(value.length == 6){
					obj.value = value + "/";
					return;
				}
			}
		}else{
			return;
		}
	}
	return ;
	*/
}

//檢查日期是否輸入正確
function checkDateConstraint(calendarObj, dateType){
	if(calendarObj.value!=null&&calendarObj.value!=""){
		var checkDateValue=calendarObj.value;
		var year;
		var month;
		var day;
		num = /\D/; 
		checkDateValue=checkDateValue.replace(/\//g,"");
		if(num.test(checkDateValue)){
			alert('您所輸入的日期型態有誤，請輸入正確日期!!!');
			calendarObj.value="";
			return false;
		}
		if(dateType=="ROC"){
			if(checkDateValue.length==6){
				checkDateValue="0"+checkDateValue;
			}else if(checkDateValue.length>7){
				alert('請使用正確日期格式 YYY/MM/DD');
				calendarObj.value="";
				return false;
			}
			year=String(Number(checkDateValue.substr(0,3))+1911);
			month=checkDateValue.substr(3,2);
			day=checkDateValue.substr(5,2);
		}else if(dateType=="AD"){
			if(checkDateValue.length>8){
				alert('請使用正確日期格式 YYYY/MM/DD');
				calendarObj.value="";
				return false;
			}
			year=checkDateValue.substr(0,4);
			month=checkDateValue.substr(4,2);
			day=checkDateValue.substr(6,2);
		}
		var objDate = new Date(year, Number(month)-1, Number(day));
		if((Number(month) > 12) || (Number(month) < 1)){
			alert('您所輸入的月份有誤，請輸入正確日期!!!');
			calendarObj.value="";
			return false;
		}else{
			if((Number(month)!= Number((objDate.getMonth()+1)))||(Number(day) != Number(objDate.getDate()))){
				alert('您所輸入的日期有誤，請輸入正確日期!!!');
				calendarObj.value="";
				return false;
			}
		}
		if(dateType=="AD"){
			calendarObj.value=year+"/"+month+"/"+day;
		}else if(dateType=="ROC"){
			year=String(Number(year)-1911);
			if(year.length==2){
				year="0"+year;
			}
			calendarObj.value=year+"/"+month+"/"+day;
		}
	}
}

//為了Firefox可取得keyCode
function whichKeyPress(e) {
	if (!e) {
		//if the browser did not pass the event 
		//information to the function, 
		//we will have to obtain it from the 
		//event register
		if (window.event) {
			//Internet Explorer
			e = window.event;
		} else {
			//total failure, we have no 
			//way of referencing the event
			return;
		}
	}
	if (typeof (e.keyCode) == 'number') {
		//DOM
		e = e.keyCode;
		return e;
	} else if (typeof (e.which) == 'number') {
		//NS 4 compatible
		e = e.which;
		return e;
	} else if (typeof (e.charCode) == 'number') {
		//also NS 6+, Mozilla 0.9+
		e = e.charCode;
		return e;
	} else {
		//total failure, we have no way of obtaining the key code
		return;
	}
}

function hiddenSlapClick(event){
	if(event.repeat){
		event.returnValue=false;
	}
}